Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp: correct --verbose --parents output for both files and directories #4184

Merged
merged 2 commits into from
Dec 12, 2022

Conversation

jfinkels
Copy link
Collaborator

This pull request corrects the behavior of cp --parents --verbose when the source path is a file and when the source path is a directory so that it prints the copied ancestor directories. For example,

$ mkdir -p a/b d
$ touch a/b/c
$ cp --verbose --parents a/b/c d
a -> d/a
a/b -> d/a/b
'a/b/c' -> 'd/a/b/c'

And

$ mkdir -p a/b/c d
$ cp -r --verbose --parents a/b/c d
a -> d/a
a/b -> d/a/b
'a/b/c' -> 'd/a/b/c'

Fixes #3332.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/misc/tee. tests/misc/tee is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

GNU testsuite comparison:

Congrats! The gnu test tests/tail-2/inotify-dir-recreate is no longer failing!
GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

GNU testsuite comparison:

GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail-2/inotify-dir-recreate. tests/tail-2/inotify-dir-recreate is passing on 'main'. Maybe you have to rebase?

@sylvestre
Copy link
Contributor

I guess the GNU regression is legit. could you please have a look?
Error: GNU test failed: tests/cp/src-base-dot. tests/cp/src-base-dot is passing on 'main'. Maybe you have to rebase?

@jfinkels
Copy link
Collaborator Author

jfinkels commented Dec 3, 2022

I think it is related to #3894 (comment) I will take a look.

@jfinkels jfinkels force-pushed the cp-verbose branch 2 times, most recently from 1b1f677 to 168837c Compare December 3, 2022 20:07
@jfinkels
Copy link
Collaborator Author

jfinkels commented Dec 3, 2022

Okay, I've made a change to the second commit in this branch. By adding this condition:

    if source_absolute.is_dir()
        && !ends_with_slash_dot(&source_absolute)
        && !local_to_target.exists()
    {

it should also fix #3897.

@github-actions
Copy link

github-actions bot commented Dec 3, 2022

GNU testsuite comparison:

GNU test failed: tests/tail-2/inotify-dir-recreate. tests/tail-2/inotify-dir-recreate is passing on 'main'. Maybe you have to rebase?

@jfinkels
Copy link
Collaborator Author

jfinkels commented Dec 3, 2022

I broke things by introducing some code to set the current working directory of the child process produced by UCommand. I'll need to adjust that a little bit to get this working.

@github-actions
Copy link

github-actions bot commented Dec 3, 2022

GNU testsuite comparison:

GNU test failed: tests/misc/tee. tests/misc/tee is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/misc/timeout. tests/misc/timeout is passing on 'main'. Maybe you have to rebase?

@github-actions
Copy link

github-actions bot commented Dec 4, 2022

GNU testsuite comparison:

Congrats! The gnu test tests/tail-2/inotify-dir-recreate is no longer failing!

This commit corrects the behavior of `cp --parents --verbose` when the
source path is a file so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b d
    $ touch a/b/c
    $ cp --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'

Fixes uutils#3332.
This commit corrects the behavior of `cp -r --parents --verbose` when
the source path is a directory, so that it prints the copied ancestor
directories. For example,

    $ mkdir -p a/b/c d
    $ cp -r --verbose --parents a/b/c d
    a -> d/a
    a/b -> d/a/b
    'a/b/c' -> 'd/a/b/c'
@sylvestre sylvestre merged commit f9c0ca4 into uutils:main Dec 12, 2022
@jfinkels jfinkels linked an issue May 2, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cp: incorrectly copies directory when path ends in dot cp-parents.sh: cp: recursive copy
2 participants